//
//  RootTabBarController.swift
//  SwiftMevos
//
//  Created by roy on 2017/4/18.
//  Copyright © 2017 roy. All rights reserved.
//

import UIKit

class RootTabBarController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 创建tabbar的子视图
        self.createSubViewControllers()
    }
    // 创建tabbar的子视图
    func createSubViewControllers() {
        //背景色
        self.tabBar.backgroundColor = UIColor.white
        
        //选中字体色
        let attributes =  [NSForegroundColorAttributeName: UIColor.colorWithHexString(rgbValue: 0x2A86E1, rgbAlpha: 1),
                           NSFontAttributeName: UIFont(name: "Heiti SC", size: 14.0)!]
        
        //视图初始化
        let firstVC = RTMainViewController()
        firstVC.view.backgroundColor = UIColor.white
        let item1 : UITabBarItem = UITabBarItem(title:"圆桌",image:UIImage(named:"rd_nor"),selectedImage:UIImage(named:"rd_sel"))
        item1.setTitleTextAttributes(attributes , for: UIControlState.selected)
        firstVC.tabBarItem = item1
        
        
        let secondVC = RCViewController()
        secondVC.view.backgroundColor = UIColor.white
        let item2:UITabBarItem = UITabBarItem(title:"推荐",image:UIImage(named:"comment_nor"),selectedImage:UIImage(named:"comment_sel"))
        item2.setTitleTextAttributes(attributes , for: UIControlState.selected)
        secondVC.tabBarItem = item2
        
        let setupVC = SetUpViewController()
        setupVC.view.backgroundColor = UIColor.white
        let item3:UITabBarItem = UITabBarItem(title:"我的",image:UIImage(named:"mine_nor"),selectedImage:UIImage(named:"mine_sel"))
        item3.setTitleTextAttributes(attributes , for: UIControlState.selected)
        setupVC.tabBarItem = item3
        
        let nav1 = BaseNavViewController(rootViewController:firstVC)
        nav1.isNavigationBarHidden = true
        let nav2 = BaseNavViewController(rootViewController:secondVC)
        nav2.isNavigationBarHidden = true
        let nav3 = BaseNavViewController(rootViewController:setupVC)
        nav3.isNavigationBarHidden = true
        self.viewControllers = [nav1,nav2,nav3]
        
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
